package com.sinosoft.dsp.platform.components;

import java.util.Map;

import javax.print.AttributeException;

import org.primefaces.json.JSONObject;

import com.sinosoft.dsp.system.core.exception.SinoException;

/**
 * 可编辑的ViewBean接口类
 * 
 * @author 潘巍（Peter Pan）
 * @since 2011-2-27 下午05:41:41
 */
public interface IEditViewBean extends IViewBean {

	public static final String EDIT_VIEWBEAN_BUTTON_SAVE = "save";
	public static final String EDIT_VIEWBEAN_BUTTON_MERGE = "merge";
	public static final String EDIT_VIEWBEAN_BUTTON_FIND = "find";
	public static final String EDIT_VIEWBEAN_BUTTON_REMOVE = "remove";
	public static final String EDIT_VIEWBEAN_BUTTON_NEXT = "next";
	public static final String EDIT_VIEWBEAN_BUTTON_FLUSH = "flush";

	public static final String VALIDATE_FLAG = "validate";
	public static final String VALIDATE_MSG = "messages";

	public String getReturnValue();

	public void setReturnValue(JSONObject returnValue);

	public Map<String, Object> getFields();
	
	public Object getField(String key);

	public void addField(String key, Object value);

	/**
	 * 保存
	 * 
	 * @return
	 * @throws AttributeException
	 */
	public void save() throws SinoException;

	/**
	 * 修改
	 * 
	 * @return
	 * @throws AttributeException
	 */
	public void merge() throws SinoException;

	/**
	 * 查找
	 * 
	 * @return
	 */
	public void find() throws SinoException;

	/**
	 * 移除
	 * 
	 * @throws AttributeException
	 */
	public void remove() throws SinoException;

	/**
	 * 跳转到下一个页面
	 * 
	 * @param viewBeanName
	 */
	public void next(String viewBeanName) throws SinoException;

	/**
	 * 刷新当前ViewBean
	 * 
	 * @throws SinoException
	 */
	public void flush() throws SinoException;

	/**
	 * 内部验证，可覆盖该方法。<br>
	 * 已经在接口中描述的验证部分不用重复验证
	 * 
	 * @param methodName
	 * 
	 * @return 验证结果
	 */
	public String[] validate(String methodName);

	/**
	 * 验证是否显示该按钮
	 * 
	 * @param btnName
	 * @return
	 */
	public boolean renderedButton(String btnName);

}
